package com.qf.mvc2203.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/users")
public class UsersController {
    @RequestMapping("/login")
    public Map<String, String> login(String username, String password, String kapchar, HttpSession session) {
      //1.校验验证码是否正确，从session中获取验证码
        String captcha = (String) session.getAttribute("captcha");
        HashMap<String, String> map = new HashMap<>();
        if (captcha.equals(kapchar)){
            map.put("code","1");
            map.put("msg","登陆成功");
        }else {
            map.put("code","1");
            map.put("msg","验证码错误");
        }
        return map;
    }
}
